﻿// Date: 18.08.11

// Revision 5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NOVA.Physics
{
    /// <summary>
    /// This class represents the motion setting parameters, which specify 
    /// the limits of the MotorizedGrabSpring for every scene object.
    /// </summary>
    public class MotionSetting
    {
        private float linearStiffness;
        private float linearDamping;
        private float maxLinearAcceleration;
        private float angularStiffness;
        private float angularDamping;
        private float maxAngularAcceleration;
        private float linearVelocityThreshold;
        private float angularVelocityThreshold;
        private float linearPositionThreshold;
        private float angularPositionThreshold;


        public float LinearStiffness 
        {
            get { return this.linearStiffness; }
            set { this.linearStiffness = value; }
        }

        public float LinearDamping 
        {
            get { return this.linearDamping; }
            set { this.linearDamping = value; }
        }

        public float MaxLinearAcceleration 
        {
            get { return this.maxLinearAcceleration; }
            set { this.maxLinearAcceleration = value; }
        }

        public float AngularStiffness 
        {
            get { return this.angularStiffness; }
            set { this.angularStiffness = value; }
        }

        public float AngularDamping 
        {
            get { return this.angularDamping; }
            set { this.angularDamping = value; }
        }

        public float MaxAngularAcceleration 
        {
            get { return this.maxAngularAcceleration; }
            set { this.maxAngularAcceleration = value; }
        }

        public float LinearVelocityThreshold 
        {
            get { return this.linearVelocityThreshold; }
            set { this.linearVelocityThreshold = value; }
        }

        public float AngularVelocityThreshold 
        {
            get { return this.angularVelocityThreshold; }
            set { this.angularVelocityThreshold = value; }
        }

        public float LinearPositionThreshold 
        {
            get { return this.linearPositionThreshold; }
            set { this.linearPositionThreshold = value; }
        }

        public float AngularPositionThreshold 
        {
            get { return this.angularPositionThreshold; }
            set { this.angularPositionThreshold = value; }
        }

        public MotionSetting()
        {
            this.linearPositionThreshold = 0.2f;
            this.linearVelocityThreshold = 0.1f;

            this.angularPositionThreshold = 0.2f;
            this.angularVelocityThreshold = 0.1f;
        }

        /// <summary>
        /// Creates an instance of a hard setting
        /// </summary>
        public static MotionSetting HardSetting
        {
            get 
            {
                MotionSetting setting = new MotionSetting();

                // Linear settings
                setting.LinearStiffness = 100000f;
                setting.LinearDamping = 10000f;
                setting.MaxLinearAcceleration = 10000f;

                // Angular settings
                setting.AngularStiffness = 60000f;
                setting.AngularDamping = 10000f;
                setting.MaxAngularAcceleration = 1000f;

                

                return setting;
            }
        }

        /// <summary>
        /// Creates an instance of a soft setting
        /// </summary>
        public static MotionSetting SoftSetting
        {
            get
            {
                MotionSetting setting = new MotionSetting();

                // Linear settings
                setting.LinearStiffness = 1000f;
                setting.LinearDamping = 10f;
                setting.MaxLinearAcceleration = 100f;

                // Angular settings
                setting.AngularStiffness = 0.1f;
                setting.AngularDamping = 0.1f;
                setting.MaxAngularAcceleration = 100f;

                return setting;
            }
        }
    }
}
